﻿using DatabaseTransfer.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace DatabaseTransfer.Tables
{
    [Serializable()]
    public class TableColumn : ISerializable
    {
        public string ColumnName { get; set; }

        public string ColumnConversion { get; set; }

        public Type ColumnType { get; set; }

        public object ColumnValue { get; set; }

        public TableColumn() { }

        public TableColumn(SerializationInfo info, StreamingContext ctxt)
        {
            this.ColumnName = (string)info.GetValue("ColumnName", typeof(string));
            this.ColumnConversion = (string)info.GetValue("ColumnConversion", typeof(string));
            this.ColumnType = (Type)info.GetValue("ColumnConversion", typeof(Type));
            this.ColumnValue = (object)info.GetValue("ColumnConversion", typeof(object));
        }

        public override string ToString()
        {
            return String.Format("Column Name: {0}, Column Type: {1}", this.ColumnName, this.ColumnType);
        }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("ColumnName", this.ColumnName);
            info.AddValue("ColumnConversion", this.ColumnConversion);
            info.AddValue("ColumnType", this.ColumnType);
            info.AddValue("ColumnValue", this.ColumnValue);
        }
    }
}
